package com.hylanda.pb.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hylanda.pb.model.ReportModel;
import com.hylanda.pb.service.PowerBiService;
import com.hylanda.pb.service.common.ConstantHelper;

/** 
 * @author zhangy
 * @E-mail:blackoon88@gmail.com 
 * @qq:846579287
 * @version created at：2018年1月18日 下午4:18:36 
 * 获取报表名列表 
 */
@RestController
@RequestMapping("/powerbi")
public class PBAzureController {
	@Autowired
	private PowerBiService powerBiService;
	
	@RequestMapping(value = { "/get/report/name/list" }, method = RequestMethod.POST)
	public JSONObject getReportNames(HttpServletRequest request,
			HttpServletResponse response,ReportModel model){
		JSONArray ja=powerBiService.getReportNames(model);
		JSONObject jo=new JSONObject();
		if(ja==null){
			jo.put("data", ConstantHelper.RESPONSE_FAIL);
		}else{
			jo.put("data", ja);
		}
		return jo;
	}
	@RequestMapping(value = { "/get/report/name" }, method = RequestMethod.POST)
	public String getReportName(HttpServletRequest request,
			HttpServletResponse response,ReportModel model){
		boolean result=powerBiService.getReportName(model);
		if(result){
			return ConstantHelper.RESPONSE_SUCCESS;
		}else{
			return ConstantHelper.RESPONSE_FAIL;
		}
	}
}
